package sort;

/**
 * Created by Administrator on 2017/3/14.
 */
public class HeapSort {
    public void sort(int [] array){
        for(int i = array.length - 1;i > 0;i--){
            buildBigHeap(array,i);
            int temp = array[0];
            array[0] = array[i];
            array[i] = temp;
        }
    }

    private void buildBigHeap(int [] array,int size){
        for(int i = size;i>0;i++){
            if(array[i] > array[i/2]){
                int temp = array[i];
                array[i] = array[i/2];
                array[i/2] = temp;
            }
        }
    }


}
